﻿using ED.Common.BaseModel;
using ED.IService;
using ED.Model.Request;
using Microsoft.AspNetCore.Mvc;

namespace ED.Admin.Controllers
{
    /// <summary>
    /// 组织机构控制器
    /// </summary>
    public class DepartmentController : CommonController
    {
        private readonly IDepartmentService departmentService;

        /// <summary>
        /// 构造器
        /// </summary>
        /// <param name="departmentService">组织机构服务</param>
        public DepartmentController(IDepartmentService departmentService)
        {
            this.departmentService = departmentService;
        }

        /// <summary>
        /// Department查询
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        [HttpPost]
        public ResponseOutput<List<DepartmentRes>> Page(DepartmentQueryReq req)
        {
            return ResponseOutput.Ok(departmentService.Page(req));
        }

        /// <summary>
        /// Department新增
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        [HttpPost]
        public ResponseOutput Add(DepartmentOperateReq req)
        {
            return departmentService.Add(req);
        }

        /// <summary>
        /// Department更新
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        [HttpPost]
        public ResponseOutput Update(DepartmentOperateReq req)
        {
            return departmentService.Update(req);
        }

        /// <summary>
        /// Department删除
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        [HttpPost]
        public ResponseOutput Delete(int req)
        {
            return departmentService.Delete(req);
        }
    }
}
